package com.java.advance.aop.staticproxy;

import com.java.advance.aop.IUserDao;

/**
 * 代理类
 * Created by yangminghua on 2019/4/4.
 */
public class UserDaoStaticProxy implements IUserDao {

    private IUserDao userDao;

    /**
     * 使用构造方法注入
     *
     * @param userDao
     */
    public UserDaoStaticProxy(IUserDao userDao) {
        this.userDao = userDao;
    }


    @Override
    public void save() {
        System.out.println("开启事务");
        userDao.save();
        System.out.println("提交事务");
    }

    @Override
    public void findById(Long id) {
        System.out.println("开启事务");
        userDao.findById(12L);
        System.out.println("提交事务");
    }
}
